-
Notifications
You must be signed in to change notification settings - Fork 709
Implement the sender side of the validation communication protocol in Rust #4280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…s more generic (do not require BufReader or BufWriter)
❌ 4 Tests Failed:
View the top 3 failed tests by shortest run time
📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4280 +/- ##
==========================================
- Coverage 34.42% 32.64% -1.78%
==========================================
Files 482 482
Lines 57031 57031
==========================================
- Hits 19631 18619 -1012
- Misses 33911 35178 +1267
+ Partials 3489 3234 -255 |
bragaigor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good and seems that most of my comments are nitpicks :)
changelog/pmikolajczyk-nit-4364.md
Outdated
| @@ -0,0 +1,3 @@ | |||
| ### Ignored | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ### Ignored | |
| ### Internal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that we added this section, thanks! fixed in eab1044
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that the ones introduced in #4269 to be substituted for these ones right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly - actually, I was partly basing this PR on your code
| if input.has_delayed_msg { | ||
| env.delayed_messages | ||
| .insert(input.delayed_msg_nr, input.delayed_msg); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will there always be just one delayed_message? Asking because before, just like sequencer_messages, delayed_messages was wrapped in a while loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
citing Tsahi:
Currently - it can only contain a single delayed message. There are future thoughs about having multiple delayed messages in a single block but that'll only happen after MEL and we could tackle it then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so there's some lack of consistency in the code, but right now I tried to persist the existing behavior and data structs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah got it, thanks!
crates/jit/src/wavmio.rs
Outdated
| let hash = socket::read_bytes32(stream)?; | ||
| let preimage = socket::read_bytes(stream)?; | ||
| for (preimage_type, preimages) in input.preimages { | ||
| let map = env.preimages.entry(preimage_type).or_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: map is a bit too generic and I know it was already there, maybe we could rename to something like preimage_map? Up to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed in 043c73f
| batch_info: inbox, | ||
| delayed_msg: delayed_message.data, | ||
| start_state, | ||
| user_wasms: HashMap::from([(local_target(), user_wasms)]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why having a HashMap instead of just user_wasms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because ValidationInput has HashMap here, in case someone wants to pass wasms for multiple different archs
| pub type IOResult<T> = Result<T, io::Error>; | ||
|
|
||
| const SUCCESS: u8 = 0x0; | ||
| const FAILURE: u8 = 0x1; | ||
| // const PREIMAGE: u8 = 0x2; // legacy, not used | ||
| const ANOTHER: u8 = 0x3; | ||
| const READY: u8 = 0x4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I don't have a strong opinion but maybe these could go into their own file constants.rs? and keep mod.rs with just the mods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to markers.rs to make it more explicit what constants they are
crates/validation/src/lib.rs
Outdated
| if self.has_delayed_msg { | ||
| Some(BatchInfo { | ||
| number: self.delayed_msg_nr, | ||
| data: self.delayed_msg.clone(), | ||
| }) | ||
| } else { | ||
| None | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick suggestion
| if self.has_delayed_msg { | |
| Some(BatchInfo { | |
| number: self.delayed_msg_nr, | |
| data: self.delayed_msg.clone(), | |
| }) | |
| } else { | |
| None | |
| } | |
| self.has_delayed_msg.then(|| BatchInfo { | |
| number: self.delayed_msg_nr, | |
| data: self.delayed_msg.clone(), | |
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crates/validation/src/lib.rs
Outdated
| pub fn local_target() -> String { | ||
| match (env::consts::OS, env::consts::ARCH) { | ||
| ("linux", "aarch64") => "arm64", | ||
| ("linux", "x86_64") => "amd64", | ||
| _ => "host", | ||
| } | ||
| .to_string() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick suggestion coming from #4269
| pub fn local_target() -> String { | |
| match (env::consts::OS, env::consts::ARCH) { | |
| ("linux", "aarch64") => "arm64", | |
| ("linux", "x86_64") => "amd64", | |
| _ => "host", | |
| } | |
| .to_string() | |
| } | |
| pub fn local_target() -> &'static str { | |
| if cfg!(all(target_os = "linux", target_arch = "aarch64")) { | |
| TARGET_ARM_64 | |
| } else if cfg!(all(target_os = "linux", target_arch = "x86_64")) { | |
| TARGET_AMD_64 | |
| } else { | |
| TARGET_HOST | |
| } | |
| } |
then the const can go into the contstants.rs file if you decide to create one:
pub(crate) const TARGET_ARM_64: &str = "arm64";
pub(crate) const TARGET_AMD_64: &str = "amd64";
pub(crate) const TARGET_HOST: &str = "host";Again up to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applied suggestion ✅
| use std::io::ErrorKind::InvalidData; | ||
| use std::io::{Error, Write}; | ||
|
|
||
| pub fn send_validation_input(writer: &mut impl Write, input: &ValidationInput) -> IOResult<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like this and send_batches, send_preimages, and send_user_wasms are only used in tests? Unless I missed their caller? If so, wouldn't it be best to move them down to the test file itself? Or we have plans to use them in the future somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hopefully all these will be used in your continuous mode (replacing existing inlined protocol) :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, that would simplify things
bragaigor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM

jittovalidationcrate.ReadandWritetraits, rather than concrete types).Note: the API is synchronous. We don't need async ops at the moment.
closes NIT-4364